<template>
    <ul class="goodsList">
        <li v-for="(item,index) in itemizeList" @click="fiftGoods(item.cid,index)">{{item.title}}</li>
    </ul>
</template>
<script>
    import {getGoodsItemizeList} from "../../api/list/list";

    export default {
        name:'goodsList',
        data(){
            return{
                itemizeList:[]
            }
        },
        created() {
            getGoodsItemizeList().then((res)=>{
                // console.log(res.data.data)
                let data = res.data.data
                this.itemizeList = data
            })
        },
        methods:{
            fiftGoods(id,index){
                this.$emit('goodsCid',id)
                this.initStyle(index)
            },
            initStyle(j){
                let li = document.getElementsByTagName("li")
                for (let i = 0; i <li.length; i++) {
                    li[i].className=""
                }
                li[j].className="active"
            },
        }
    }
</script>
<style lang="less" scoped>
    .goodsList{
        width: 1.5rem;
        height: 100%;
        text-align: center;
        overflow: auto;
        li{
            background: white;
            height: 0.8rem;
            line-height: 0.8rem;
            border-bottom: 1px solid #efefef;
        }
        .active{
            color: red;
        }
    }
</style>